﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CSharpDesign.DAL;
using CSharpDesign.Scripts;

namespace CSharpDesign
{
    public partial class OrderChk : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();
        public string OrderStite;
        public string IstuiHuo;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request.QueryString["Orderid"].ToString();
                SqlHelper data = new SqlHelper();
                SqlDataReader dr;
                string sql = "select * from GouWuChe where Orderid='" + id + "'";
                dr = data.GetDataReader(sql);
                dr.Read();
                OrderStite = dr["OrderStite"].ToString();

                TextBox1.Text = dr["WuLiu"].ToString();

            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string id = Request.QueryString["Orderid"].ToString();
            SqlHelper data = new SqlHelper();
            SqlDataReader dr;
            string sql = "select * from GouWuChe where Orderid='" + id + "'";
            dr = data.GetDataReader(sql);
            dr.Read();
            OrderStite = dr["OrderStite"].ToString();
            IstuiHuo = dr["OrderStite"].ToString();
            TextBox1.Text = dr["WuLiu"].ToString();

            if (OrderStite == "待评价")
            {
                Alert.AlertAndRedirect("已经操作过了不能在进行操作", "MyOrder.aspx");

            }
            else if (OrderStite == "待发货")
            {
                Alert.AlertAndRedirect("还没有发货您不能操作订单", "MyOrder.aspx");
            }

            else
            {
                data.RunSql("update GouWuChe set OrderStite='待评价' where Orderid='" + id + "'");
                Alert.AlertAndRedirect("操作成功", "DDPJ.aspx");

            }
        }

    }

}